#include "halfedge.h"
#include "edge.h"
#include <iostream>


HalfEdge::HalfEdge()
{

}

void HalfEdge::setWloop(Loop* _loop)
{
	wloop = _loop;
}

void HalfEdge::setNxt(HalfEdge* _he)
{
	nxt = _he;
}

void HalfEdge::setPrv(HalfEdge* _he)
{
	prv = _he;
}

void HalfEdge::setVtx(Vertex* _vertex)
{
	vtx = _vertex;
}
void HalfEdge::setEdg(Edge* _edge)
{
	edg = _edge;
}

Loop* HalfEdge::getLoop()
{
	return wloop;
}

HalfEdge* HalfEdge::mate()
{
  if( this->edg == NULL )
    return this;

	if( this == this->edg->getHe1() )
	{
		return this->edg->getHe2();
	}
	else
	{
		return this->edg->getHe1();
	}
}

HalfEdge* HalfEdge::getNxt()
{
	return nxt;
}

Edge* HalfEdge::getEdg()
{
	return edg;
}
HalfEdge* HalfEdge::getPrv()
{
	return prv;
}
Vertex* HalfEdge::getVtx()
{
	return vtx;
}



HalfEdge* 
HalfEdge::delhe()
{
  if(this->edg == NULL)
  {
    //del(HALFEDGE, this, NULL);
    return(NULL);
  }
  else if(this->nxt == this)
  {
    this->edg = NULL;
    return(this);
  }
  else
  {
    this->prv->nxt = this->nxt;
    this->nxt->prv = this->prv;
    //del(HALFEDGE, this, NULL);
    return(this->prv);
  }
}
